package my.jieh.tips.util.collection;

/**
 * <p>Title: Core Java Technologies Tech Tips</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: Blueimp</p>
 * @author jieh
 * @version 1.0
 */

public class CollectionTest {
  public static void main(String[] args) {
    java.util.LinkedList ll = new java.util.LinkedList();
    java.util.Vector v = new java.util.Vector();
    int count = 0;
    long s = 0l;

    for (int i = 0; i < 1000000; i++) {
      ll.add("test");
      v.addElement("test");
    }

    System.out.println();
    s = System.currentTimeMillis();
    java.util.Iterator itr = v.iterator();
    count = 0;
    while (itr.hasNext()) {
      itr.next();
      count++;
    }
    System.out.println("ITERATOR : " + (System.currentTimeMillis() - s));

    System.out.println();
    s = System.currentTimeMillis();
    itr = ll.iterator();
    count = 0;
    while (itr.hasNext()) {
      itr.next();
      count++;
    }
    System.out.println("LinkedList : " + (System.currentTimeMillis() - s));

    System.out.println();
    s = System.currentTimeMillis();
    for (int i = 0; i < v.size(); i++) {
      v.elementAt(i);
    }
    System.out.println("VECTOR call by size : " +
                       (System.currentTimeMillis() - s));

    System.out.println();
    s = System.currentTimeMillis();
    int l = v.size();
    for (int i = 0; i < l; i++) {
      v.elementAt(i);
    }
    System.out.println("VECTOR pro : " + (System.currentTimeMillis() - s));
  }
}